package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-23 17:10
 * @Modified By:
 */
public class FindErrorNums_645 {
    public static void main(String[] args){

    }

    public static int[] findErrorNums(int[] nums){
        int dup = -1, missing = -1;
        for (int i = 1; i <= nums.length; i++) {
            int count = 0;
            for (int j = 0; j < nums.length; j++) {
                if (nums[j] == i)
                    count++;
            }
            // 为2说明找到了出错的数据
            if (count == 2)
                dup = i;
            // 为0就说明找到了丢失的数据  正常情况下count应该为1
            else if (count == 0)
                missing = i;
        }
        return new int[] {dup, missing};
    }
}
